package com.api.shopapi.service.impl;

import com.api.shopapi.entity.NursingRecord;
import com.api.shopapi.mapper.NursingRecordMapper;
import com.api.shopapi.service.NursingRecordService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

@Service("NursingRecordServiceImplOne")
public class NursingRecordServiceImpl  implements NursingRecordService {

    @Autowired
    private NursingRecordMapper nursingRecordMapper;


    @Override
    public int insert(NursingRecord nursingRecord) {
        return nursingRecordMapper.insert(nursingRecord);
    }

    @Override
    public int update(NursingRecord nursingRecord) {
        return nursingRecordMapper.update(nursingRecord);
    }

    @Override
    public int delete(String nursingRecordCode) {
        return nursingRecordMapper.delete(nursingRecordCode);
    }

    @Override
    public PageInfo<NursingRecord> getPageList(int pageIndex, int pageSize, String institutionCode) {
        PageHelper.startPage(pageIndex, pageSize);
        List<NursingRecord> nursingRecords = nursingRecordMapper.getListByInstitutionCode(institutionCode);
        PageInfo<NursingRecord> pageInfo = new PageInfo<>(nursingRecords);
        return pageInfo;
    }


    @Override
    public NursingRecord getByNursingRecordCode(String nursingRecordCode) {
        return nursingRecordMapper.getByNursingRecordCode(nursingRecordCode);
    }

    @Override
    public
    PageInfo<NursingRecord> getPageListByElderlyCode(int pageIndex, int pageSize, String elderlyCode) {
        PageHelper.startPage(pageIndex, pageSize);
        List<NursingRecord> nursingRecords = nursingRecordMapper.getPageListByElderlyCode(elderlyCode);
        PageInfo<NursingRecord> pageInfo = new PageInfo<>(nursingRecords);
        return pageInfo;
    }

    @Override
    public
    List<NursingRecord> listByElderlyCodeTime(String elderlyCode, Date beginTime,Date endTime){
        return nursingRecordMapper.listByElderlyCodeTime(elderlyCode,beginTime,endTime);
    }

    @Override
    public
    PageInfo<NursingRecord> pageByGovCode(int pageIndex, int pageSize, String governmentCode){
        PageHelper.startPage(pageIndex, pageSize);
        List<NursingRecord> nursingRecords = nursingRecordMapper.listByGovCode(governmentCode);
        PageInfo<NursingRecord> pageInfo = new PageInfo<>(nursingRecords);
        return pageInfo;
    }

    @Override
    public
    List<NursingRecord> listByGovCodeStatus(String governmentCode, int status){
        return nursingRecordMapper.listByGovCodeStatus(governmentCode,status);
    }


    @Override
    public
    List<NursingRecord> listByMedicinerCode(String medicinerCode,int status){
        return nursingRecordMapper.listByMedicinerCode(medicinerCode,status);
    }

    @Override
    public
    List<NursingRecord> listByNurseCode(String nurseCode,int status){
        return nursingRecordMapper.listByNurseCode(nurseCode,status);
    }

    @Override
    public
    List<NursingRecord> listByNurseAideCode(String nurseAideCode,int status){
        return nursingRecordMapper.listByNurseAideCode(nurseAideCode,status);
    }


    @Override
    public
    PageInfo<NursingRecord> pageByMedicinerCode(int pageIndex, int pageSize, String medicinerCode,int status){
        PageHelper.startPage(pageIndex, pageSize);
        List<NursingRecord> nursingRecords = nursingRecordMapper.listByMedicinerCode(medicinerCode,status);
        PageInfo<NursingRecord> pageInfo = new PageInfo<>(nursingRecords);
        return pageInfo;
    }

    @Override
    public
    PageInfo<NursingRecord> pageByNurseCode(int pageIndex, int pageSize, String nurseCode,int status){
        PageHelper.startPage(pageIndex, pageSize);
        List<NursingRecord> nursingRecords = nursingRecordMapper.listByNurseCode(nurseCode,status);
        PageInfo<NursingRecord> pageInfo = new PageInfo<>(nursingRecords);
        return pageInfo;
    }

    @Override
    public
    PageInfo<NursingRecord> pageByNurseAideCode(int pageIndex, int pageSize, String nurseAideCode,int status){
        PageHelper.startPage(pageIndex, pageSize);
        List<NursingRecord> nursingRecords = nursingRecordMapper.listByNurseAideCode(nurseAideCode,status);
        PageInfo<NursingRecord> pageInfo = new PageInfo<>(nursingRecords);
        return pageInfo;
    }


    @Override
    public
    PageInfo<NursingRecord> pageByInstitutionCode(int pageIndex, int pageSize, String institutionCode,int status){
        PageHelper.startPage(pageIndex, pageSize);
        List<NursingRecord> nursingRecords = nursingRecordMapper.listByInsCode(institutionCode,status);
        PageInfo<NursingRecord> pageInfo = new PageInfo<>(nursingRecords);
        return pageInfo;
    }




}
